home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGASIC / CDITPDS2.LZH / DEMOW1.BAS < prev    next >
BASIC Source File  |  1991-06-05  |  10KB  |  275 lines

  1. '============================================================================
  2. 'DEMOW1.BAS Copyright (C) 1991, Clear Software. ALL RIGHTS RESERVED.
  3. '============================================================================
  4.  
  5. '$INCLUDE: 'CITOOLS.BI'
  6. '$INCLUDE: 'CIWIND1.BI'
  7. '$INCLUDE: 'CIMOUSE.BI'
  8.  
  9. '============================================================================
  10.  
  11. DEFINT A-Z
  12.  
  13. '============================================================================
  14.  
  15. CONST TRUE = -1, FALSE = 0
  16.  
  17. '============================================================================
  18.  
  19. '============================================================================
  20. 'Inititalize the mouse and paint the background.
  21. '============================================================================
  22.  
  23.     MouseInit
  24.  
  25.     CLS
  26.     COLOR 15, 7
  27.     ScreenPaint 2, 79, 2, 22, ""
  28.     DrawBox 1, 80, 1, 23, 2
  29.  
  30. '============================================================================
  31. 'Define the window.
  32. '============================================================================
  33.     
  34.     WindowDefine 1, 20, 60, 6, 16, "Button/Edit Field", 0, 2
  35.     WindowColors 7, 1, 7, 1, 15, 1, 1, 3
  36.     
  37. '============================================================================
  38. 'Show the window.
  39. '============================================================================
  40.                    
  41.     WindowOn 1
  42.  
  43. '============================================================================
  44. 'Put the buttons and edit fields on the window.
  45. '============================================================================
  46.  
  47.     ButtonDefine 1, 1, 1, 2, 3, " Who ", 3
  48.     ButtonDefine 1, 2, 0, 2, 10, " What ", 3
  49.     ButtonDefine 1, 3, 0, 2, 18, " When ", 3
  50.     ButtonDefine 1, 4, 0, 2, 26, " Exit ", 3
  51.  
  52.     ButtonDefine 1, 5, 1, 4, 6, "Button 4", 2
  53.     ButtonDefine 1, 6, 0, 4, 23, "Button 5", 2
  54.  
  55.     ButtonDefine 1, 7, 1, 7, 3, " Where       ", 5
  56.     ButtonDefine 1, 8, 0, 8, 3, " Why         ", 5
  57.     ButtonDefine 1, 9, 0, 9, 3, " How         ", 5
  58.  
  59.     EditFieldDefine 1, 10, "", 7, 19, 12, 20, "Fld 1:", 1
  60.     EditFieldDefine 1, 11, "", 9, 19, 12, 11, "Fld 2:", 2
  61.  
  62.     EditFieldColors 7, 0
  63.  
  64. '============================================================================
  65. 'Draw the lines and the box in the window.
  66. '============================================================================
  67.  
  68.     WindowDrawLine 1, 3, "─"
  69.     WindowDrawLine 1, 5, "─"
  70.     WindowDrawBox 1, 2, 16, 6, 10, 2
  71.     
  72. '============================================================================
  73. 'Place the cursor on the first item when the window is made active. Also
  74. 'set cursor for the group buttons when one of the groups is selected.
  75. '============================================================================
  76.  
  77.     item = 1
  78.  
  79.     curGp1 = 1
  80.     curGp2 = 5
  81.     curGp3 = 7
  82.     
  83.  
  84. '============================================================================
  85. 'Show the mouse and enter the window loop. The first select case determines
  86. 'which item is current and prints the correct description line for it.
  87. '============================================================================
  88.  
  89.     WDONE = FALSE
  90.     MouseShow
  91.  
  92.     WHILE NOT WDONE
  93.  
  94.         MouseHide
  95.         COLOR 0, 7
  96.         LOCATE 23, 2: PRINT SPACE$(78)
  97.         SELECT CASE item
  98.             CASE 1, 2, 3, 4
  99.                 LOCATE 23, 2
  100.                 PRINT " <ARROW=Next Item>   <TAB=Next Button Set>   <ENTER=Accept>   <ESCAPE=Exit>"; ""
  101.                
  102.             CASE 5
  103.                 LOCATE 23, 2
  104.                 PRINT " <SPACE BAR=Toggle Button>    <TAB=Next Button>    <ESCAPE=Exit>"; ""
  105.                
  106.             CASE 6
  107.                 LOCATE 23, 2
  108.                 PRINT " <SPACE BAR=Toggle Button>    <TAB=Next Button Set>    <ESCAPE=Exit>"; ""
  109.                
  110.             CASE 7, 8, 9
  111.                 LOCATE 23, 2
  112.                 PRINT " <ARROW=Next Item>    <TAB=Go To Edit Field 1>    <ESCAPE=Exit>"; ""
  113.                
  114.             CASE 10
  115.                 LOCATE 23, 2
  116.                 PRINT " <TAB=Go To Edit Field 2>    <ESCAPE=Exit>"
  117.  
  118.             CASE 11
  119.                 LOCATE 23, 2
  120.                 PRINT " <TAB=Next Button Set>    <ESCAPE=Exit>"
  121.  
  122.         END SELECT
  123.  
  124.         MouseShow
  125. '============================================================================
  126. 'Make the window active. When a key or mouse button is pressed find out which
  127. 'one.
  128. '============================================================================
  129.  
  130.         WindowActive item
  131.  
  132.         SELECT CASE WindowEvent(0)              'Find out what took place.
  133.  
  134.             CASE 1                              'A mouse event took place so
  135.                 SELECT CASE WindowEvent(1)      'find out on which button or
  136.                     CASE 4                      'edit field.
  137.                         WDONE = TRUE
  138.  
  139.                     CASE 1, 2, 3
  140.                         item = WindowEvent(1)
  141.                         curGp1 = item
  142.  
  143.                     CASE 7, 8, 9
  144.                         ButtonToggle curGp3
  145.                         item = WindowEvent(1)
  146.                         curGp3 = item
  147.                         ButtonToggle curGp3
  148.  
  149.                     CASE 10, 11
  150.                         item = WindowEvent(1)
  151.                         
  152.                     CASE 5, 6
  153.                         ButtonToggle curGp2
  154.                         curGp2 = WindowEvent(1)
  155.                         ButtonToggle curGp2
  156.                         item = curGp2
  157.                         
  158.                 END SELECT
  159.  
  160.              CASE 2                             'A key was pressed so find out
  161.                 SELECT CASE WindowEvent(2)      'which key and what button or
  162.                     CASE 1                      'edit field th cursor was on.
  163.                         SELECT CASE item
  164.                             CASE 4
  165.                                 WDONE = TRUE
  166.                         END SELECT
  167.                         
  168.                     CASE 2
  169.                         WDONE = TRUE
  170.  
  171.                     CASE 3
  172.                         SELECT CASE item
  173.                             CASE 1, 2, 3
  174.                                 item = 5
  175.                             
  176.                             CASE 4
  177.                                 ButtonToggle item
  178.                                 item = 5
  179.                                 ButtonToggle 1
  180.                                 curGp1 = 1
  181.  
  182.                             CASE 5
  183.                                item = item + 1
  184.  
  185.                             CASE 6
  186.                                 item = curGp3
  187.  
  188.                             CASE 7, 8, 9
  189.                                 curGp3 = item
  190.                                 item = 10
  191.                                 
  192.  
  193.                             CASE 10
  194.                                 item = item + 1
  195.  
  196.                             CASE 11
  197.                                 item = curGp1
  198.  
  199.                         END SELECT
  200.                      
  201.                      CASE 5
  202.                         SELECT CASE item
  203.                             CASE 7, 8, 9
  204.                                 ButtonToggle item
  205.                                 item = item - 1
  206.                                 IF item < 7 THEN
  207.                                     item = 9
  208.                                 END IF
  209.                                 ButtonToggle item
  210.                                 curGp3 = item
  211.                         END SELECT
  212.  
  213.                      CASE 6
  214.                         SELECT CASE item
  215.                             CASE 7, 8, 9
  216.                                 ButtonToggle item
  217.                                 item = item + 1
  218.                                 IF item > 9 THEN
  219.                                     item = 7
  220.                                 END IF
  221.                                 ButtonToggle item
  222.                                 curGp3 = item
  223.                         END SELECT
  224.  
  225.  
  226.                      CASE 7
  227.                         SELECT CASE item
  228.                             CASE 5, 6
  229.                                 ButtonToggle item
  230.                         END SELECT
  231.  
  232.  
  233.                      CASE 8
  234.  
  235.                         SELECT CASE item
  236.                             CASE 1, 2, 3, 4
  237.                                 ButtonToggle item
  238.                                 item = item - 1
  239.                                 IF item < 1 THEN
  240.                                     item = 4
  241.                                 END IF
  242.                                 ButtonToggle item
  243.                                 curGp1 = item
  244.                         END SELECT
  245.  
  246.                      CASE 9
  247.                         SELECT CASE item
  248.                             CASE 1, 2, 3, 4
  249.                                 ButtonToggle item
  250.                                 item = item + 1
  251.                                 IF item > 4 THEN
  252.                                     item = 1
  253.                                 END IF
  254.                                 ButtonToggle item
  255.                                 curGp1 = item
  256.                          END SELECT
  257.  
  258.  
  259.                  END SELECT
  260.  
  261.        END SELECT
  262.     WEND
  263.  
  264.  
  265. '============================================================================
  266. 'The user chose to exit so hide the mouse and clean up the screen.
  267. '============================================================================
  268.  
  269.     MouseHide
  270.  
  271.     COLOR 7, 0
  272.     CLS
  273.     END
  274.  
  275.